﻿using System.Windows;
using System.Timers;

namespace Using_Timer {
  public partial class MainWindow : Window {
    public MainWindow() {
      InitializeComponent();
      DataContext = data_;
      timer_.Enabled = false;
      timer_.Interval = 1000;
      timer_.Elapsed += this.Tick;
      count_ = 0;
    }

    private void button1_Click(object sender, RoutedEventArgs e) {
      timer_.Interval = slider1.Value;
      timer_.Enabled = true;
    }

    private void button2_Click(object sender, RoutedEventArgs e) {
      timer_.Enabled = false;
    }

    private void Tick(object sender, ElapsedEventArgs e) {
      ++count_;
      data_.setText(count_.ToString());
    }

    private BindData data_ = new BindData();
    private Timer timer_ = new Timer();
    private int count_;
  }
}
